import React, { lazy } from "react";
import lazySuspense from "./lazySuspense";

import Main from "@pages/main02";
import Page404 from "@components/404";

const Login02 = lazy(() => import("@pages/login02"));
const Calendar = lazy(() => import("@pages/calendar"));
const Todos = lazy(() => import("@pages/calendar/todos"));
const CustomizeFestival = lazy(() =>
    import("@pages/calendar/customizeFestival")
);
const Games = lazy(() => import("@pages/games"));
const FlappyBird = lazy(() => import("@pages/games/flappyBird"));
const MessageBoard = lazy(() => import("@pages/messageBoard"));
const PreviousFonc = lazy(() => import("@pages/messageBoard/previousFonc"));
const UnderDevelopment = lazy(() =>
    import("@pages/messageBoard/underDevelopment")
);
const AllMessages = lazy(() => import("@pages/messageBoard/allMessages"));
const AcceptMessage = lazy(() => import("@pages/messageBoard/acceptMessage"));
const MessageRank = lazy(() => import("@pages/messageBoard/messageRank"));
const MyMessages = lazy(() => import("@pages/messageBoard/myMessages"));
const PublishMessage = lazy(() => import("@pages/messageBoard/publishMessage"));
const ReadMessage = lazy(() => import("@pages/messageBoard/readMessage"));
const WebChat = lazy(() => import("@pages/webChat"));
const Chat = lazy(() => import("@pages/webChat/chat"));
const AddressBook = lazy(() => import("@pages/webChat/addressBook"));
const NewFriendsList = lazy(() =>
    import("@pages/webChat/addressBook/newFriendsList")
);
const AddrBookMask = lazy(() => import("@pages/webChat/addressBook/mask"));
const ChatMask = lazy(() => import("@pages/webChat/chat/mask"));
const ChatWindow = lazy(() => import("@pages/webChat/chat/chatWindow"));

const ele = [
    {
        path: "/",
        element: lazySuspense(Main),
    },
    {
        path: "/login",
        element: lazySuspense(Login02),
    },
    {
        path: "/calendar",
        element: lazySuspense(Calendar),
    },
    {
        path: "/todos",
        element: lazySuspense(Todos),
    },
    {
        path: "/customizeFestival",
        element: lazySuspense(CustomizeFestival),
    },
    {
        path: "/games",
        children: [
            {
                path: "",
                element: lazySuspense(Games),
            },
            {
                path: "flappyBird",
                element: lazySuspense(FlappyBird),
            },
        ],
    },
    {
        path: "/messageBoard",
        // element: lazySuspense(MessageBoard),
        children: [
            // 子路由必须配合Outlet使用，不然无效
            {
                path: "",
                element: lazySuspense(MessageBoard),
            },
            {
                path: "previous-fonc",
                element: lazySuspense(PreviousFonc),
            },
            {
                path: "under-development",
                element: lazySuspense(UnderDevelopment),
            },
            {
                path: "all-messages",
                element: lazySuspense(AllMessages),
            },
            {
                path: "accept-message",
                element: lazySuspense(AcceptMessage),
            },
            {
                path: "message-rank",
                element: lazySuspense(MessageRank),
            },
            {
                path: "my-message",
                element: lazySuspense(MyMessages),
            },
            {
                path: "publish-message",
                element: lazySuspense(PublishMessage),
            },
            {
                path: ":id",
                element: lazySuspense(ReadMessage),
            },
        ],
    },
    {
        path: "/web-chat",
        element: lazySuspense(WebChat),
        children: [
            {
                path: "chat",
                element: lazySuspense(Chat),
                children: [
                    {
                        path: "mask",
                        element: lazySuspense(ChatMask),
                    },
                    {
                        path: "chat-window/:id",
                        element: lazySuspense(ChatWindow),
                    },
                ],
            },
            {
                path: "address-book",
                element: lazySuspense(AddressBook),
                children: [
                    {
                        path: "mask",
                        element: lazySuspense(AddrBookMask),
                    },
                    {
                        path: "new-friends-list",
                        element: lazySuspense(NewFriendsList),
                    },
                ],
            },
        ],
    },
    {
        path: "*",
        element: <Page404 />,
    },
];

export default ele;
